<!-- Layout.vue -->
<template>
    <div>
      <header class="header">
        <div class="logo">
          <img src="@/assets/icon.png" alt="Logo" class="icon" /> <!-- 修改为您的图标路径 -->
          <span class="site-name">红星党建</span>
        </div>
        <nav class="nav">
          <router-link to="/">首页</router-link>
          <router-link to="/location">党建地点</router-link>
          <router-link to="/forum">论坛</router-link>
          <router-link to="/news">公告资讯</router-link>
          <router-link to="/store">商城</router-link>
          <router-link to="/profile">个人中心</router-link>
        </nav>
        <div class="avatar" @click="toggleDropdown">
          <img src="@/assets/avatar.png" alt="头像" class="avatar-icon" /> <!-- 修改为您的头像路径 -->
          <div v-if="isDropdownVisible" class="dropdown">
            <router-link to="/personal-center">个人中心</router-link>
            <a @click.prevent="logout">退出登录</a>
          </div>
        </div>
      </header>
  
      <main>
        <slot />
      </main>
    </div>
  </template>
  
  <script>
  export default {
    name: "Layout",
    data() {
      return {
        isDropdownVisible: false,
      };
    },
    methods: {
      toggleDropdown() {
        this.isDropdownVisible = !this.isDropdownVisible;
      },
      logout() {
        // 在这里处理退出登录逻辑
        alert("退出登录");
      },
    },
  };
  </script>
  
  <style scoped>
  .header {
    display: flex;
    align-items: center;
    background-color: red;
    padding: 10px 20px;
    color: white;
  }
  
  .logo {
    display: flex;
    align-items: center;
    margin-right: auto;
  }
  
  .icon {
    width: 40px;
    height: 40px;
    margin-right: 10px;
  }
  
  .site-name {
    font-size: 24px;
    font-weight: bold;
  }
  
  .nav {
    display: flex;
    margin: 0 20px;
  }
  
  .nav a {
    color: white;
    text-decoration: none;
    margin: 0 15px;
  }
  
  .nav a:hover {
    text-decoration: underline;
  }
  
  .avatar {
    position: relative;
    cursor: pointer;
  }
  
  .avatar-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
  
  .dropdown {
    position: absolute;
    right: 0;
    background-color: white;
    color: black;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
  }
  
  .dropdown a {
    display: block;
    padding: 10px;
    text-decoration: none;
    color: black;
  }
  
  .dropdown a:hover {
    background-color: #f0f0f0;
  }
  </style>
  